/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Engine;

import Vue.Camera;
import Vue.IElementGraphique;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.geom.Rectangle;

/**
 *
 * @author Ivelios
 */
public abstract class Entite implements IElementGraphique{

    protected float posX;
    protected float posY;
    protected Image image;
    protected float rotation;
    protected Camera camera;

    public Entite(){
        camera = Camera.getInstance();   
    }

    public Entite(float posX, float posY, Image image, float rotation) {
        this();
        this.posX = posX;
        this.posY = posY;
        this.image = image;
        this.rotation = rotation;
        
    }

    public Entite(float posX, float posY, String strImage, float rotation) throws SlickException {
        this();
        this.posX = posX;
        this.posY = posY;
        this.image = new Image(strImage);
        this.rotation = rotation;
    }


    public int getWidth() {
        return image.getWidth();
    }

    public int getHeight() {
        return image.getHeight();
    }

    public void setImage(Image image) {
        this.image = image;
    }

    public void setPosX(int posX) {
        this.posX = posX;
    }

    public void setPosY(int posY) {
        this.posY = posY;
    }

    public void setRotation(float rotation) {
        this.rotation = rotation;
    }

    public Image getImage() {
        return image;
    }

    public float getPosX() {
        return posX;
    }

    public float getPosY() {
        return posY;
    }

    public float getRotation() {
        return rotation;
    }

    public float getMiddleX(){
        return  posX + (image.getWidth()/2);
    }
    public float getMiddleY(){
        return  posY + (image.getHeight()/2);
    }
    
    public Rectangle getRectangle(){
        return new Rectangle(posX,posY,image.getWidth(),image.getHeight());
    }

    public void init(GameContainer container) throws SlickException{

    }
    public void update(GameContainer gc, int delta){

    }

    public void render(GameContainer gc, Graphics g){
        g.rotate(camera.getPosX()+getMiddleX(), camera.getPosY()+getMiddleY(), rotation);
        g.drawImage(image, camera.getPosX()+posX, camera.getPosY()+posY);
        
    }

    

    
}
